'\"macro stdmacro
.\"
.\" Copyright (c) 2016,2022 Red Hat.
.\" Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMGETARCHIVELABEL 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmGetArchiveLabel\f1 \- fetch the label record from a set of performance metrics archives
.SH "C SYNOPSIS"
.ft 3
.ad l
.hy 0
#include <pcp/pmapi.h>
.sp
int pmGetArchiveLabel(pmLogLabel *\fIlp\fP);
.sp
cc ... \-lpcp
.hy
.ad
.ft 1
.SH DESCRIPTION
.de CR
.ie t \f(CR\\$1\f1\\$2
.el \fI\\$1\f1\\$2
..
Within the framework of the
Performance Co-Pilot (PCP), archives of performance metrics
values may be accumulated and saved using the program
.BR pmlogger (1)
and the
.BR LOGIMPORT (3)
programming interface.
.PP
The routines
.B pmGetArchiveLabel
may be used to fetch the label record from a set of archives
that has already been opened using
.BR pmNewContext (3),
or
.BR pmDupContext (3),
and thereby associated with the current
Performance Metrics Application Programming Interface (PMAPI)
context.
.PP
The result returned via the pointer
.I lp
is a structure that must be pre-allocated by the caller
and has the following format (defined in
.BR pmapi.h ).
.PP
.in +0.2i
.ft CR
.nf
typedef struct {
  int        magic;       /* PM_LOG_MAGIC | archive format version no. */
  pid_t      pid;         /* PID of logger */
  struct timespec start;  /* start of this archive */
  char       hostname[PM_MAX_HOSTNAMELEN];   /* collection host full name */
  char       timezone[PM_MAX_TIMEZONELEN];   /* generic, squashed $TZ */
  char       zoneinfo[PM_MAX_ZONEINFOLEN];   /* local platform $TZ */
} pmLogLabel;
.fi
.ft 1
.in
.PP
.B pmGetArchiveLabel
can be used with either version 2 or version 3 archives,
however some mapping may be required with the older version 2
archives, e.g. the
.I start
time only has microsecond resolution and the
.I zoneinfo
field is not present.
For detailed information about the archive on-disk format, refer to
.BR LOGARCHIVE (5).
.PP
For an application using
.BR pmGetArchiveLabel ,
the most useful information from the archive label
is likely to be in the fields
.CR start ,
.CR hostname ,
.CR timezone ,
and
.CR zoneinfo .
.PP
The
.CR zoneinfo
field contains the most detailed timezone information available,
and should be used if present (non-zero length string).
It will only not be present in the case of version 2 archives \-
this is a new field added as part of the version 3 format.
The
.CR timezone
field will always be present, however it is the 'squashed' timezone
value and in certain situations is not the most accurate timezone.
.PP
For older applications using
.BR pmGetArchiveLabel ,
the most useful information from the archive label
is likely to be in the fields
.CR ll_start ,
.CR ll_hostname
or
.CR ll_tz .
Note that the size of the
.CR ll_hostname
field is
.CR PM_LOG_MAXHOSTLEN
(64 bytes)
which is less than
.BR MAXHOSTNAMELEN
(see
.BR gethostbyname (3))
on some platforms.
These semantics are necessary to retain backwards compatibility with
the PCP archive file format.
.PP
.B pmGetArchiveLabel
return zero for success.
.SH COMPATIBILITY
Prior to PCP 7.0 and
.I libpcp.so.4
the
.I pmLogLabel
structure was somewhat different.
To support PMAPI transition, the old interface and semantics can be
used if applications are linked with
.I libpcp.so.3
or recompiled with
.BR \-DPMAPI_VERSION=2 .
.PP
For a time in PCP 6.x there was a
routine with the same semantics as the current
.B pmGetArchiveLabel
called
.B pmGetHighResArchiveLabel
and a structure with same definition as
.I pmLogLabel
called
.I pmHighResLogLabel
although these are now deprecated and compile-time support for
.B pmGetHighResArchiveLabel
and
.I pmHighResLogLabel
will be removed in a future release.
.SH DIAGNOSTICS
.IP \f3PM_ERR_NOCONTEXT\f1
the current PMAPI context
is either invalid, or not associated with a set of archives
.SH "PCP ENVIRONMENT"
Environment variables with the prefix
.B PCP_
are used to parameterize the file and directory names
used by PCP.
On each installation, the file
.I /etc/pcp.conf
contains the local values for these variables.
The
.B $PCP_CONF
variable may be used to specify an alternative
configuration file,
as described in
.BR pcp.conf (5).
Values for these variables may be obtained programmatically
using the
.BR pmGetConfig (3)
function.
.SH SEE ALSO
.BR pmlogger (1),
.BR LOGIMPORT (3),
.BR PMAPI (3),
.BR pmDupContext (3),
.BR pmGetConfig (3),
.BR pmNewContext (3),
.BR LOGARCHIVE (5),
.BR pcp.conf (5)
and
.BR pcp.env (5).

.\" control lines for scripts/man-spell
.\" +ok+ pre {from pre-allocated}
